<?php
namespace Home\Controller;
use Home\Core\VmsSDK;
use Think\Controller;

class LoginController extends HttpController
{
    public function __construct()
    {
        parent::__construct();
    }


    public function login()
    {
        $this->display();
    }
    public function login_post(){
        $data = I('post.');
        $password=$data['password'];
        $param['username'] = $data['userName'];
        $param['password'] = substr(md5("$password"),0,16);
        $sdk = new VmsSDK();
        $return = $this->http_request($sdk::LOGIN,$param,'GET');
        $result = $return->result;//获取result的值
        $uid = $return->userid;
        $data['id'] = $uid;
        if($result==0){
            session('user_info',$data);
        }
        $this->ajaxReturn($result);
    }
    public function logout(){
        session('user_info',null);
        $this->redirect('Home/Login/login');
    }
}